package com.itboye.eweilisten.me.timu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.model.TIbeanTwo;
import com.itboye.eweilisten.util.widget.OtherGridView;

import java.util.List;

/**
 * Created by Itboye-000018 on 2017/6/5.
 */

public class XuanZeImgAdapter  extends RecyclerView.Adapter<XuanZeImgAdapter.MyViewHolder>  {
    Context context;
    private List<TIbeanTwo> beans;
    TiAtwoAdapter adapter;

    public XuanZeImgAdapter(Context context, List<TIbeanTwo> beans) {
        this.context = context;
        this.beans = beans;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.zuo_ti_a_two,null,false);
        MyViewHolder holder=new MyViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.two_title.setText(beans.get(position).getTitle());

        adapter = new TiAtwoAdapter(context, beans.get(position).getOption(),beans.get(position).getAnwser_true(),position, beans, R.layout.item_shangcheng01);

        holder.goods_gridView.setAdapter(adapter);
    }


    @Override
    public int getItemCount() {
        return beans.size();
    }

    // 自定义的ViewHolder，持有每个Item的的所有界面元素
    public class MyViewHolder extends RecyclerView.ViewHolder {
        public TextView two_title;
        public OtherGridView goods_gridView;

        public MyViewHolder(View itemView) {
            super(itemView);
            two_title = (TextView) itemView.findViewById(R.id.two_title);
            goods_gridView = (OtherGridView) itemView.findViewById(R.id.goods_gridView);
        }
    }
}
